/*
 * author      : dormi330
 * date        : 2018/7/16
 * description : 消息对象
 */

package com.deep.trade.common;

public class BaseMssage extends BaseDto {
    private String msgId;
    private String className;
    private String body;

    public static BaseMssage fromObject(BaseDto obj) {
        return new BaseMssage(
                CommonUtils.uuid(),
                obj.getClass().getCanonicalName(),
                obj.uglyString()
        );
    }

    public BaseMssage(String msgId, String className, String body) {
        this.msgId = msgId;
        this.className = className;
        this.body = body;
    }

    public BaseMssage() {
    }

    public <T> T parseObject(Class<T> clazz) {
        return CommonUtils.fromJsonString(body, clazz);
    }

    // setter/getter
    public String getMsgId() {
        return msgId;
    }

    public void setMsgId(String msgId) {
        this.msgId = msgId;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }


}
